from flask import Flask, render_template, session, redirect, url_for
from flask_bootstrap import Bootstrap
from flask_wtf import Form
from wtforms import StringField, SubmitField, TextAreaField

app = Flask(__name__)
bootstrap = Bootstrap(app)
app.config['SECRET_KEY'] = "Echo"

class InputForm(Form):  
    inputText = StringField('Input: ')
    submit = SubmitField('Submit')
    outputText = TextAreaField('Output: ')

@app.route('/', methods=['GET', 'POST'])
def index(): 
    form = InputForm()
    if form.validate_on_submit():
        session['output'] = form.inputText.data
        return redirect(url_for('index'))
    form.outputText.data = session.get('output')
    return render_template('index.html', form=form)

if __name__ == "__main__":
    app.run(host="0.0.0.0", port=80, debug=True)
